package com.damai.plugins.impl;

import java.util.ArrayList;
import java.util.List;

import com.citywithincity.db.ConnectionDescription;
import com.citywithincity.db.Db;
import com.damai.plugins.IPlugin;

public class DbPlugin implements IPlugin {
	private List<ConnectionDescription> dbs;
	
	public DbPlugin(){
		dbs = new ArrayList<ConnectionDescription>();
	}
	
	public void add(ConnectionDescription connectionDescription){
		dbs.add(connectionDescription);
	}

	public void start() {
		ConnectionDescription[] cds = new ConnectionDescription[dbs.size()];
		dbs.toArray(cds);
		Db.create(cds);
	}

	public void stop() {
		Db.close();
	}

}
